<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>项目流程跟踪页面</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <div class="fieldBox" style="display:none;">
            <input name="linkId" id="linkId" type="text" class="ui-textbox" value="${linkId}">
        </div>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/project/prjlnkcomp/initPrjlnFlowList.do?linkId=${linkId}',
            method: 'get',
            columns: [
                {display: '业务数据编号', name: 'grpFlag', minwidth: 120, enabledSort: true},
                {
                    display: '流程名称', name: 'pno', minWidth: 180, align: 'center', enabledSort: true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        h = '<a href="javascript:showFlow(';
                        h += "'" + rowdata.pinstId + "',"; //流程实例ID
                        h += "'" + rowdata.audStsCd + "',"; //审核状态
                        h += "'" + rowdata.dataId + "',"; //业务主键ID
                        h += "'" + rowdata.busTyp + "'"; //业务类型
                        h += ')">' + value + '</a>';
                        return h;
                    }
                },
                {
                    display: '状态', name: 'audStsCd', minwidth: 120, enabledSort: true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        if (rowdata.audStsCd == "0") {
                            h = '待提交';
                        } else if (rowdata.audStsCd == "1") {
                            h = '审核中';
                        } else if (rowdata.audStsCd == "2") {
                            h = '审核通过';
                        } else if (rowdata.audStsCd == "3") {
                            h = '审核不通过';
                        }
                        return h;
                    }
                },
                {display: '创建人', name: 'crtUsrName', minwidth: 120, enabledSort: true},
                {display: '创建时间', name: 'pCrtTm', minWidth: 140, render: renderDate, enabledSort: false},
            ],
            //pageSize:10,
            usePager: false,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: false,
            rownumbers: true,
            onAfterShowData: function () {
                $('#ligergrid1').rowspan('grpFlag');
            }
        });
        grid = liger.get("ligergrid1");
        grid.setHeight(100);
        $("#searchBar").ligerForm();
        $("#searchBtn").click(function (event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            data["crtTm"] = $("#crtTm").val();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            ;
            grid.reload();
        });

        $("#pageloading").hide();

    });


    //显示流程
    function showFlow(_pInstId, _audStsCd, _businessKey,busTyp) {
        if (StringUtils.isEmpty(_pInstId)) {
            UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
            return;
        }
        var _formUrl="";
        if(busTyp == '031'){//供应商变更流程
            _formUrl = "/project/prjLnkCompApply/modifyProcess.do?audStsCd=1@@applyId=";
        }else{
            _formUrl = "/project/prjlnkcomp/toDetailPage.do?id=" + _businessKey + "@@processInstanceId=" + _pInstId + "@@projectId=";
        }
        var params = "?pInsId=" + _pInstId + "&status=" + _audStsCd + "&businessKey=" + _businessKey + "&formUrl=" + _formUrl;
        Add_navTab('tab_prj_lnk_comp_flow_' + _businessKey, '查看流程', "<%=path%>/flow/flow/toFlowShowPageFowBus.do" + params);
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

</script>

</body>
</html>